package com.android.myapplication.view;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Spinner;

import com.android.myapplication.R;
import com.android.myapplication.main.BaseActvity;
import com.android.myapplication.view.adapter.RecycleAdapterDemo;
import com.android.myapplication.view.adapter.StudentAdapter;
import com.android.myapplication.view.adapter.StudentBean;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

public class RecyclerViewActivity extends BaseActvity {
    private String[] data = {"Apple1", "Apple2", "Apple3", "Apple4", "Apple5", "Apple6",
            "Apple7", "Apple8", "Apple9", "Apple10", "Apple11", "Apple12", "Apple13", "Apple14",
            "Apple15", "Apple16", "Apple17", "Apple18", "Apple19", "Apple20"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_recycler);
        RecyclerView  recyclerView = findViewById(R.id.recycler);

        List<StudentBean> studentBeanList = new ArrayList<>();
        Random random = new Random();
        for(int i = 0; i < 10; i ++){
            studentBeanList.add(new StudentBean("张" + (i + 1), random.nextInt(1), random.nextInt(5) + 16, "http://img2.imgtn.bdimg.com/it/u=2934897295,342218263&fm=26&gp=0.jpg", "软171401"));
        }
        recyclerView.setAdapter(new RecycleAdapterDemo(this, studentBeanList));
        GridLayoutManager  linearLayoutManager = new GridLayoutManager(this,3, RecyclerView.HORIZONTAL, false);
        recyclerView.setLayoutManager(linearLayoutManager);

    }
}
